{% extends "base.html" %}

{% block title %}注册 - 畅读小说网{% endblock %}

{% block content %}
<div class="login-container">
    <h2>用户注册</h2>

    {% if messages %}
    <div class="messages">
        {% for message in messages %}
        <div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">
            {{ message }}
        </div>
        {% endfor %}
    </div>
    {% endif %}

    <form method="post" action="{% url 'register' %}">
        {% csrf_token %}
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" name="username" id="username" required minlength="3" maxlength="20">
            <small class="form-text text-muted">用户名长度为3-20个字符</small>
        </div>
        <div class="form-group">
            <label for="email">电子邮箱</label>
            <input type="email" name="email" id="email" required>
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" name="password" id="password" required minlength="6">
            <small class="form-text text-muted">密码至少6个字符</small>
        </div>
        <div class="form-group">
            <label for="confirm_password">确认密码</label>
            <input type="password" name="confirm_password" id="confirm_password" required>
        </div>
        <div class="form-check">
            <input type="checkbox" name="agree_terms" id="agree_terms" class="form-check-input" required>
            <label for="agree_terms" class="form-check-label">我已阅读并同意<a href="#">用户协议</a>和<a href="#">隐私政策</a></label>
        </div>
        <button type="submit" class="btn btn-success">注册</button>
    </form>

    <div class="register-link">
        <p>已有账号？<a href="{% url 'login' %}">立即登录</a></p>
    </div>
</div>
{% endblock %}